import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './assets/css/global.css'
import axios from 'axios'
// 引入nprogress加入进度条
import NProgress from 'nprogress'
import MD5 from "./util/MD5Util";

// 设置全局地址调用(生产环境采用是 nginx 转发解决跨域问题)
axios.defaults.baseURL = 'http://106.13.180.6:8001/proxy/api/';
// 拦截器设置请求头添加Token , 可以展示进度条 start()
axios.interceptors.request.use(config => {
  NProgress.start();
  let timestamp = new Date().getTime();
  config.headers.common['Timestamp'] = timestamp;
  config.headers.common['Authorization'] = MD5(timestamp);
  return config;
});
// response 中可以隐藏进度条 down()
axios.interceptors.response.use(config => {
  NProgress.done();
  return config;
});

// 将axios挂载到全局Vue上面
Vue.prototype.$http = axios;


Vue.config.productionTip = false;

new Vue({
  router,
  render: h => h(App)
}).$mount('#app');
